﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.OleDb;
using DTO;
namespace DAO
{
    public class TheLoaiDAO
    {
        DataProvider dp;
        public TheLoaiDAO()
        {
            dp = new DataProvider();
        }
        public DataTable LayDSTheLoai()
        {
            string sql = "select * from TheLoai";
            DataTable table = new DataTable();
            table = dp.LayBangDuLieu(sql);
            return table;
        }
        public bool ThemTheLoai(string tentheloai)
        {
            bool flag = true;
            string sql = "INSERT INTO TheLoai(tentheloai) VALUES ('" + tentheloai + "')";

            if (dp.ThucHienCauTruyVan(sql)) flag = true;
            else flag = false;
            return flag;
        }
        public string LayTenTheLoai(int matheloai)
        {
            string tentheloai = "";
            string sql = "select * from TheLoai where matheloai = " + matheloai + "";
            DataTable table = new DataTable();
            table = dp.LayBangDuLieu(sql);
            DataRow dtr = table.Rows[0];
            tentheloai = dtr[1].ToString();
            return tentheloai;
        }
    }
}
